const Base = require('./base.js');
module.exports = class extends Base {
	async getChilds(pid) {
		let childs = await this.where({ pid: pid }).select();
		return childs;
	}
	async getChildIds(pid) {
		let childIds = [pid];
		let childs = await this.getChilds(pid);
		for(let c of childs) {
			childIds.push(c.id);
			if(c.hasChildren == 1) {
				let secondChilds = await this.getChilds(c.id);
				for(let s of secondChilds) {
					childIds.push(s.id);
					if(s.hasChildren == 1) {
						let thirdChilds = await this.getChilds(s.id);
						for(let t of thirdChilds) {
							childIds.push(t.id);
						}
					}
				}
			}
		}
		return childIds;
	}
};